<template>
  <div class="scan">
    <form name='pushMsgFm' report-submit @submit='orderSign' class="tepForm"  v-if="!code_value">
        <div style="width: 100%;color:white;text-align: center;margin-bottom: 3px">您已获得每日积分前100名奖励</div>
        <div style="width: 100%;color:white;text-align: center;margin-bottom: 10px">“点击领取”获得兑换券</div>
        <button form-type="submit"  class="commit">
            <img src="http://file.rzkeji.com/web/f6/game/exchangeBtn.png" alt="" mode="scaleToFill">
        </button>
    </form>
    <div v-else class="qrcode_wrapper">
      <img :src="qrCodeUrl" class="qrcode" >
    </div>
    
  </div>
</template>

<script>

export default {
  data () {
    return {
      code_value:'',
      qrCodeUrl:''
    }
  },
  methods: {
   async orderSign(e){
      // this.$currency.showToast(e.target.formId)
      let userToken=wx.getStorageSync('userToken')
      const res=await this.$request.postData('/game/getMyYouCouponMsg',{
        form_id:e.target.formId,
        user_token:userToken
      }
    )
    this.$currency.showToast(res.data.message)
    },
    async getQrcode(){
      const res=await this.$request.getData('/game/getQrcodeByCode',{
        code_value:this.code_value
      })
      if(res.data.level=='success'){
          this.qrCodeUrl=res.data.data.photo_url
      }
      console.log(this.qrCodeUrl,55555)
    }
  },
  onLoad(options){
    if(options.code_value){
      // this.$currency.showToast(options.code_value,8888)
      this.code_value=options.code_value
      this.getQrcode()
    }
  }

}
</script>
<style lang="scss" scoped>
  .scan{
    width:100%;
    height: 100%;  
    background:url('http://file.rzkeji.com/web/f6/game/exchange.png');
    background-size: 100% 100%;
  }
  .commit{
    width:120px;
    height: 40px;
    background: #bcaf9a;
    position: relative;
  }
  .commit img{
    top:0;
    left: 0;
    position: absolute;
    width:120px;
    height: 40px;
  }
  .tepForm{
    position: relative;
    top:450px
    // bottom: 50px;
  }
  .qrcode_wrapper{
    position: absolute;
    bottom: 10px;
    width: 100%;
    text-align: center;
  }
  .qrcode{
    display: inline-block;
    width: 200px;
    height: 200px;
  }
</style>

